/**
 * mysqld
 * mysql -u root -h localhost -p
 * 
 * create database painworld;
 * grant all privileges on painworld.* to 'painworld'@'%' identified by 'painworld';
 * grant all privileges on painworld.* to 'painworld'@'localhost' identified by 'painworld'; 
 * flush privileges;
 * 
 *  @author newbie
 *  @since 0.1
 */
package test.db.table.mysql;

import org.junit.Ignore;
import org.junit.Test;

import test.db.util.DBUtil;

public class MySqlInitDb {

    private String query_pw_bbs = null;
    private String query_pw_bbs_manager = null;
    private String query_pw_bbs_history = null;
    private String query_pw_bbs_type = null;
    private String query_pw_bbs_env = null;
    private String query_pw_category = null;
    private String query_pw_bbs_file = null;
    private String query_pw_bbs_memo = null;
    private String query_pw_bbs_rate = null;
    private String query_pw_bbs_star = null;
    private String query_pw_bbs_tag = null;
    private String query_pw_tag = null;
    private String query_pw_user = null;
    private String query_pw_user_trace = null;
    private String query_pw_authority = null;
    private String query_pw_attach_file = null;
    private String query_pw_primary_code = null;
    private String query_pw_secondary_code = null;
    private String query_pw_login_history = null;
    private String query_pw_ip_country = null;
    private String query_pw_table_row_count = null;

    public MySqlInitDb() {
    	query_pw_bbs = MySqlTableList.PW_BBS.getQuery();
    	query_pw_bbs_manager = MySqlTableList.PW_BBS_MANAGER.getQuery();
    	query_pw_bbs_history = MySqlTableList.PW_BBS_HISTORY.getQuery();
    	query_pw_bbs_type = MySqlTableList.PW_BBS_TYPE.getQuery();
    	query_pw_bbs_env = MySqlTableList.PW_BBS_ENV.getQuery();
        query_pw_category = MySqlTableList.PW_BBS_CATEGORY.getQuery();
        query_pw_bbs_file = MySqlTableList.PW_BBS_FILE.getQuery();
        query_pw_bbs_memo = MySqlTableList.PW_BBS_MEMO.getQuery();
        query_pw_bbs_rate = MySqlTableList.PW_BBS_RATE.getQuery();
        query_pw_bbs_star = MySqlTableList.PW_BBS_STAR.getQuery();
        query_pw_bbs_tag = MySqlTableList.PW_BBS_TAG.getQuery();
        query_pw_tag = MySqlTableList.PW_TAG.getQuery();
        query_pw_user = MySqlTableList.PW_USER.getQuery();
        query_pw_user_trace = MySqlTableList.PW_USER_TRACE.getQuery();
        query_pw_authority = MySqlTableList.PW_AUTHORITY.getQuery();
        query_pw_attach_file = MySqlTableList.PW_ATTACH_FILE.getQuery();
        query_pw_primary_code = MySqlTableList.PW_PRIMARY_CODE.getQuery();
        query_pw_secondary_code = MySqlTableList.PW_SECONDARY_CODE.getQuery();
        query_pw_login_history = MySqlTableList.PW_LOGIN_HISTORY.getQuery();
        query_pw_ip_country = MySqlTableList.PW_IP_COUNTRY.getQuery();
        query_pw_table_row_count = MySqlTableList.PW_TABLE_ROW_COUNT.getQuery();
    }

    @Test
    public void initTable() throws Exception {
        DBUtil.createTable(query_pw_bbs, MySqlTableList.PW_BBS.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_manager, MySqlTableList.PW_BBS_MANAGER.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_history, MySqlTableList.PW_BBS_HISTORY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_type, MySqlTableList.PW_BBS_TYPE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_env, MySqlTableList.PW_BBS_ENV.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_category, MySqlTableList.PW_BBS_CATEGORY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_file, MySqlTableList.PW_BBS_FILE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_memo, MySqlTableList.PW_BBS_MEMO.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_rate, MySqlTableList.PW_BBS_RATE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_star, MySqlTableList.PW_BBS_STAR.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_bbs_tag, MySqlTableList.PW_BBS_TAG.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_tag, MySqlTableList.PW_TAG.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_user, MySqlTableList.PW_USER.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_user_trace, MySqlTableList.PW_USER_TRACE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_authority, MySqlTableList.PW_AUTHORITY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_attach_file, MySqlTableList.PW_ATTACH_FILE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_primary_code, MySqlTableList.PW_PRIMARY_CODE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_secondary_code, MySqlTableList.PW_SECONDARY_CODE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_login_history, MySqlTableList.PW_LOGIN_HISTORY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_ip_country, MySqlTableList.PW_IP_COUNTRY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.createTable(query_pw_table_row_count, MySqlTableList.PW_TABLE_ROW_COUNT.getTableName(), DBUtil.TYPE.MYSQL);
    }

//    @Ignore
    @Test
    public void initData() throws Exception {
    	MySqlTableList.PW_BBS.initData();
    	MySqlTableList.PW_BBS_MANAGER.initData();
//    	MySqlTableList.PW_BBS_HISTORY.initData();
//    	MySqlTableList.PW_BBS_TYPE.initData();
//    	MySqlTableList.PW_BBS_ENV.initData();
//    	MySqlTableList.PW_BBS_CATEGORY.initData();
//    	MySqlTableList.PW_BBS_FILE.initData();
//    	MySqlTableList.PW_BBS_MEMO.initData();
//    	MySqlTableList.PW_BBS_RATE.initData();
//    	MySqlTableList.PW_BBS_STAR.initData();
//    	MySqlTableList.PW_BBS_TAG.initData();
//    	MySqlTableList.PW_TAG.initData();
//    	MySqlTableList.PW_USER.initData();
//    	MySqlTableList.PW_USER_TRACE.initData();
//    	MySqlTableList.PW_AUTHORITY.initData();
//    	MySqlTableList.PW_ATTACH_FILE.initData();
//    	MySqlTableList.PW_PRIMARY_CODE.initData();
//    	MySqlTableList.PW_SECONDARY_CODE.initData();
//    	MySqlTableList.PW_LOGIN_HISTORY.initData();
//    	MySqlTableList.PW_IP_COUNTRY.initData();
//    	MySqlTableList.PW_TABLE_ROW_COUNT.initData();
    }
    
    @Ignore
    @Test
    public void dropTable() throws Exception {
        DBUtil.dropTable(MySqlTableList.PW_AUTHORITY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_HISTORY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_MANAGER.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_TYPE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_ENV.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_CATEGORY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_FILE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_MEMO.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_RATE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_STAR.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_BBS_TAG.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_TAG.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_USER.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_USER_TRACE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_ATTACH_FILE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_SECONDARY_CODE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_PRIMARY_CODE.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_LOGIN_HISTORY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_IP_COUNTRY.getTableName(), DBUtil.TYPE.MYSQL);
        DBUtil.dropTable(MySqlTableList.PW_TABLE_ROW_COUNT.getTableName(), DBUtil.TYPE.MYSQL);
    }
}